package com.dajun.listener;

import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *  结束任务监听类
 */

@Component("endListener")
public class EndListener implements TaskListener {
    @Resource
    private RuntimeService runtimeService;
    @Override
    public void notify(DelegateTask task) {
        //todo 任务结束监听类，后续根据业务需求添加相应服务

        String eventName = task.getEventName();
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessStatus = processInstance.getBusinessStatus();
    }
}
